import request from '@/utils/request.js'
import axios from '@/utils/request.js'
import { getToken } from '@/utils/token.js'

export const loginAPI = ({ mobile, code }) =>request({
  url: '/v1_0/authorizations',
  method: 'POST',
  data: {
    mobile,
    code
  }
})
// 获取个人资料(错误接口)
export const userInfoAPI = () => {
  return request({
    url: '/v1_0/user'
  })
}
// 获取编辑个人资料（错误接口）
export const userProfileAPI = () => {
  return request ({
    url: '/v1_0/user/profile'
  })
}
export const userChannelAPI = () => request({
  url: '/v1_0/user/channels',
  method: 'GET',
  headers: {
    Authorization: `Bearer ${getToken()}` 
  }
})
// 文章 - 获取列表
export const articlesListAPI = ({ channelId }) => {
  return request({
    url: '/v1_0/articles',
    params: {
      channel_id: channelId,
      timestamp: (new Date()).getTime()
    }
  })
}

export const getAllChannelsAPI = () => {
  return axios({
    url: '/v1_0/channels',
    method: 'GET'
  })
}